package com.ycy.dynamic.f;

/**
 * @author kevin.ma
 * @date 2020/3/23
 */
public enum CompletionConditionEnum {

    /** if one of the instances completed, the task will pass*/
    ONE(1, "${nrOfCompletedInstances>0}", "任一完成则完成"),

    /** only all of the instances completed, the task will pass */
    ALL(2, "${nrOfCompletedInstances/nrOfInstances>=1}", "全部完成才完成"),

    /** if the specify the number of the instances completed, the task will pass */
    SPECIFY(3, "${nrOfCompletedInstances>=%s}", "完成任务个数达到指定个数"),

    /** if the proportion number of the instances completed, the task will pass  */
    PROPORTION(4, "${nrOfCompletedInstances/nrOfInstances>=%s}", "完成任务个数和任务总个数达到指定比例"),
    ;

    private int type;

    private String completionCondition;

    private String desc;

    CompletionConditionEnum(int type, String completionCondition, String desc){
        this.type = type;
        this.completionCondition = completionCondition;
        this.desc = desc;
    }

    public static CompletionConditionEnum byType(int type){
        for(CompletionConditionEnum completionConditionEnum : CompletionConditionEnum.values()){
            if(type == completionConditionEnum.getType()){
                return completionConditionEnum;
            }
        }
        return null;
    }

    public int getType() {
        return type;
    }

    public String getCompletionCondition() {
        return completionCondition;
    }

    public String getDesc() {
        return desc;
    }
}
